package com.jxud.controller;

import com.jxud.Pojo.Result;
import com.jxud.service.MinioService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@CrossOrigin(origins = "*")
@RestController
@Slf4j
// minio 上传商品图片
public class FileUploadController{

    @Autowired
    private MinioService minioService;

    @PostMapping("/api/images/upload")
    public Result uploadFile(@RequestParam("file") MultipartFile file) throws Exception {
        log.info("========================================Minio上传照片=================================================");
        String url = minioService.uploadFile(file);
        return Result.success(url);
    }
}